<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    const origin = {
        name:"admin",
        age:18
    }
    
    const target = new Proxy(origin, {
        get(obj, attr){
            console.log(`正在获取 ${JSON.stringify(obj)} 的 ${attr}`)
            return obj[attr];
        },
        set(obj, attr, val){
            console.log(`正在修改 ${JSON.stringify(obj)} 的 ${attr} 为 ${val}`)
            obj[attr] = val;
            return true;
        }
    })

    console.log(origin);
    console.log(origin.name);
    console.log(origin.age);

    origin.sex = "男";

    target.name = "张三"
    target.age = 20
    target.sex = "女"

    target.name;
    target.age;
    target.sex;

    console.log(target);

</script>
</html>